package org.lanqiao.ssm.common.memcached;

import com.danga.MemCached.MemCachedClient;
import com.danga.MemCached.SockIOPool;
/**
 * 
* @Title: MemCacheHelper.java 
* @Package org.lanqiao.ssm.common.memcached 
* @Description: TODO(MemCache帮助类) 
* @author 刘伟  15818570028@163.com   
* @date 2016年8月20日 下午3:08:49 
* @version V1.0
 */
public class MemCacheHelper {
	private static MemCachedClient mcc = new MemCachedClient();

	private MemCacheHelper() {
	}

	static {
		String[] servers = { "192.168.0.107:11211","192.168.0.103:11211" };
		Integer[] weights = { 2,2 };
		SockIOPool pool = SockIOPool.getInstance();
		pool.setServers(servers);
		pool.setWeights(weights);
		pool.setInitConn(5);
		pool.setMinConn(5);
		pool.setMaxConn(250);
		
		pool.setMaxIdle(1000 * 60 * 60 * 6);
		pool.setMaintSleep(30);
		pool.setNagle(false);// 禁用nagle算法
		pool.setSocketConnectTO(0);
		pool.setSocketTO(3000);// 3秒超时
		//pool.setHashingAlg(3);// 设置为一致性hash算法
		pool.initialize();
	}

	public static MemCachedClient getMemCachedClient() {
		return mcc;
	}
}